package days9.subclasses_are_initialized_after_inheritance;

class Animal {

    private String name;

    public Animal() {
    }

    public Animal(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Animal{" + "name='" + name + '\'' + '}';
    }
}

class Dog extends Animal {
    private String type;

    public Dog() {
        // 没有显式调用父类构造方法。 但是JVM会自动去调用。相当于
        // super()
    }

    public Dog(String type) {
        // 这个就是显式的调用父类构造方法。
        super("animal");
        this.type = type;
    }

    @Override
    public String toString() {
        return "Dog{" + "type='" + type + '\'' + '}';
    }
}